/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CadastroVendedores.java
 *
 * Created on 18/10/2011, 13:49:38
 */
package frames.Cadastro;
import classes.Distribuidor;
import classes.Vendedor;
import frames.Gerenciamento.*;
import frames.Menus.*;
import java.awt.Color;
import java.util.ArrayList;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import logicaBancoDeDados.ConectaDistribuidor;
import logicaBancoDeDados.ConectaVendedores;

/**
 *
 * @author User
 */
public class CadastroVendedores extends javax.swing.JFrame {
    public DefaultListModel modeloLista = new DefaultListModel();
    public Vendedor vendedor = new Vendedor();
    public ConectaVendedores conexao = new ConectaVendedores();
    public CadastroVendedores() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTextField3 = new javax.swing.JTextField();
        jButton4 = new javax.swing.JButton();
        jTextField4 = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        panelDados = new javax.swing.JPanel();
        lbNome = new javax.swing.JLabel();
        tfNome = new javax.swing.JTextField();
        tfTelefone = new javax.swing.JTextField();
        lbTelefone = new javax.swing.JLabel();
        lbEmpresa = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        listaEmpresa = new javax.swing.JList();
        ConectaDistribuidor conectaDistribuidor = new ConectaDistribuidor();
        listarEmpresas(conectaDistribuidor.listAll());
        panelBoato = new javax.swing.JPanel();
        btCadastrar = new javax.swing.JButton();
        btLimpar = new javax.swing.JButton();
        btVoltar = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        menuArquivo = new javax.swing.JMenu();
        itemMenuPrincipal = new javax.swing.JMenuItem();
        itemMenuCadastro = new javax.swing.JMenuItem();
        itemMenuGerenciamento = new javax.swing.JMenuItem();
        itemFechar = new javax.swing.JMenuItem();
        menuCadastro = new javax.swing.JMenu();
        itemCadastraDistribuidores = new javax.swing.JMenuItem();
        itemCadastraVendedores = new javax.swing.JMenuItem();
        itemCadastraProdutos = new javax.swing.JMenuItem();
        itemCadastraSaidaEstoque = new javax.swing.JMenuItem();
        menuGerenciamento = new javax.swing.JMenu();
        itemGerenciaCategorias = new javax.swing.JMenuItem();
        itemGerenciaDistribuidores = new javax.swing.JMenuItem();
        itemGerenciaGarantias = new javax.swing.JMenuItem();
        itemGerenciaProdutos = new javax.swing.JMenuItem();
        itemGerenciaVendedores = new javax.swing.JMenuItem();
        menuAjuda = new javax.swing.JMenu();
        itemSobre = new javax.swing.JMenuItem();

        jTextField3.setText("jTextField3");

        jButton4.setText("jButton4");

        jTextField4.setText("jTextField4");

        jList1.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane1.setViewportView(jList1);

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Cadastra Vendedor");

        panelDados.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados"));

        lbNome.setText("Nome:");

        tfNome.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                corNome(evt);
            }
        });

        tfTelefone.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                colorTelefone(evt);
            }
        });

        lbTelefone.setText("Telefone:");

        lbEmpresa.setText("Empresa:");

        listaEmpresa.setModel(modeloLista);
        listaEmpresa.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                corLista(evt);
            }
        });
        jScrollPane2.setViewportView(listaEmpresa);

        javax.swing.GroupLayout panelDadosLayout = new javax.swing.GroupLayout(panelDados);
        panelDados.setLayout(panelDadosLayout);
        panelDadosLayout.setHorizontalGroup(
            panelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDadosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelDadosLayout.createSequentialGroup()
                        .addComponent(lbNome)
                        .addGap(18, 18, 18)
                        .addComponent(tfNome, javax.swing.GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panelDadosLayout.createSequentialGroup()
                        .addComponent(lbTelefone)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tfTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panelDadosLayout.createSequentialGroup()
                        .addComponent(lbEmpresa)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE)))
                .addContainerGap())
        );
        panelDadosLayout.setVerticalGroup(
            panelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDadosLayout.createSequentialGroup()
                .addGroup(panelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbNome)
                    .addComponent(tfNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbTelefone)
                    .addComponent(tfTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelDadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbEmpresa)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE))
                .addContainerGap())
        );

        panelDadosLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {tfNome, tfTelefone});

        btCadastrar.setText("Cadastrar");
        btCadastrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCadastrarActionPerformed(evt);
            }
        });

        btLimpar.setText("Limpar");
        btLimpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btLimparActionPerformed(evt);
            }
        });

        btVoltar.setText("Voltar");
        btVoltar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btVoltarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelBoatoLayout = new javax.swing.GroupLayout(panelBoato);
        panelBoato.setLayout(panelBoatoLayout);
        panelBoatoLayout.setHorizontalGroup(
            panelBoatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelBoatoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btCadastrar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btLimpar)
                .addGap(6, 6, 6)
                .addComponent(btVoltar)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        panelBoatoLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btCadastrar, btLimpar, btVoltar});

        panelBoatoLayout.setVerticalGroup(
            panelBoatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelBoatoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelBoatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btVoltar)
                    .addComponent(btCadastrar)
                    .addComponent(btLimpar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        menuArquivo.setText("Menu");

        itemMenuPrincipal.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.SHIFT_MASK));
        itemMenuPrincipal.setText("Menu Principal");
        itemMenuPrincipal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemMenuPrincipalActionPerformed(evt);
            }
        });
        menuArquivo.add(itemMenuPrincipal);

        itemMenuCadastro.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.SHIFT_MASK));
        itemMenuCadastro.setText("Menu Cadastro");
        itemMenuCadastro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemMenuCadastroActionPerformed(evt);
            }
        });
        menuArquivo.add(itemMenuCadastro);

        itemMenuGerenciamento.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_G, java.awt.event.InputEvent.CTRL_MASK));
        itemMenuGerenciamento.setText("Menu Gerenciamento");
        itemMenuGerenciamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemMenuGerenciamentoActionPerformed(evt);
            }
        });
        menuArquivo.add(itemMenuGerenciamento);

        itemFechar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0));
        itemFechar.setText("Fechar");
        itemFechar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemFecharActionPerformed(evt);
            }
        });
        menuArquivo.add(itemFechar);

        jMenuBar1.add(menuArquivo);

        menuCadastro.setText("Cadastro");

        itemCadastraDistribuidores.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.CTRL_MASK));
        itemCadastraDistribuidores.setText("Distribuidores");
        itemCadastraDistribuidores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemCadastraDistribuidoresActionPerformed(evt);
            }
        });
        menuCadastro.add(itemCadastraDistribuidores);

        itemCadastraVendedores.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_SPACE, java.awt.event.InputEvent.CTRL_MASK));
        itemCadastraVendedores.setText("Vendedores");
        itemCadastraVendedores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemCadastraVendedoresActionPerformed(evt);
            }
        });
        menuCadastro.add(itemCadastraVendedores);

        itemCadastraProdutos.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ENTER, 0));
        itemCadastraProdutos.setText("Produtos");
        itemCadastraProdutos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemCadastraProdutosActionPerformed(evt);
            }
        });
        menuCadastro.add(itemCadastraProdutos);

        itemCadastraSaidaEstoque.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        itemCadastraSaidaEstoque.setText("Saida de Estoque");
        itemCadastraSaidaEstoque.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemCadastraSaidaEstoqueActionPerformed(evt);
            }
        });
        menuCadastro.add(itemCadastraSaidaEstoque);

        jMenuBar1.add(menuCadastro);

        menuGerenciamento.setText("Gerenciamento");

        itemGerenciaCategorias.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        itemGerenciaCategorias.setText("Categorias");
        itemGerenciaCategorias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemGerenciaCategoriasActionPerformed(evt);
            }
        });
        menuGerenciamento.add(itemGerenciaCategorias);

        itemGerenciaDistribuidores.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        itemGerenciaDistribuidores.setText("Distribuidores");
        itemGerenciaDistribuidores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemGerenciaDistribuidoresActionPerformed(evt);
            }
        });
        menuGerenciamento.add(itemGerenciaDistribuidores);

        itemGerenciaGarantias.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_G, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        itemGerenciaGarantias.setText("Garantias");
        itemGerenciaGarantias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemGerenciaGarantiasActionPerformed(evt);
            }
        });
        menuGerenciamento.add(itemGerenciaGarantias);

        itemGerenciaProdutos.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        itemGerenciaProdutos.setText("Produtos");
        itemGerenciaProdutos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemGerenciaProdutosActionPerformed(evt);
            }
        });
        menuGerenciamento.add(itemGerenciaProdutos);

        itemGerenciaVendedores.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        itemGerenciaVendedores.setText("Vendedores");
        itemGerenciaVendedores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemGerenciaVendedoresActionPerformed(evt);
            }
        });
        menuGerenciamento.add(itemGerenciaVendedores);

        jMenuBar1.add(menuGerenciamento);

        menuAjuda.setText("Ajuda");

        itemSobre.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F12, 0));
        itemSobre.setText("Sobre");
        itemSobre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemSobreActionPerformed(evt);
            }
        });
        menuAjuda.add(itemSobre);

        jMenuBar1.add(menuAjuda);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelDados, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(65, Short.MAX_VALUE)
                .addComponent(panelBoato, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelDados, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelBoato, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btCadastrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCadastrarActionPerformed
        if(tfNome.getText().isEmpty() || tfTelefone.getText().isEmpty() || listaEmpresa.getSelectedValuesList().isEmpty()){
            if(tfNome.getText().isEmpty()){
                tfNome.setBackground(Color.red);
            }
            if(tfTelefone.getText().isEmpty()){
                tfTelefone.setBackground(Color.red);
            }
            if(listaEmpresa.getSelectedValuesList().isEmpty()){
                listaEmpresa.setBackground(Color.red);
            }
        }else{
            vendedor.setNome(tfNome.getText());
            vendedor.setEmpresa(listaEmpresa.getSelectedValuesList().toString());
            vendedor.setTelefone(tfTelefone.getText());
            conexao.insere(vendedor);            
        }
        
    }//GEN-LAST:event_btCadastrarActionPerformed

   private void itemMenuPrincipalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemMenuPrincipalActionPerformed
        new MenuPrincipal().setVisible(true);
        dispose();
    }//GEN-LAST:event_itemMenuPrincipalActionPerformed

    private void itemMenuCadastroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemMenuCadastroActionPerformed
        new MenuCadastro().setVisible(true);
    }//GEN-LAST:event_itemMenuCadastroActionPerformed

    private void itemMenuGerenciamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemMenuGerenciamentoActionPerformed
        new MenuGerenciamento().setVisible(true);
    }//GEN-LAST:event_itemMenuGerenciamentoActionPerformed

    private void itemFecharActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemFecharActionPerformed
        int resposta = JOptionPane.showConfirmDialog(null, "Deseja realmente encerrar o programa", "Confirmação", JOptionPane.YES_NO_OPTION);
        if (resposta == 0) {
            System.exit(0);
            dispose();
        }
    }//GEN-LAST:event_itemFecharActionPerformed

    private void itemCadastraDistribuidoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemCadastraDistribuidoresActionPerformed
        new CadastroDistribuidores().setVisible(true);
    }//GEN-LAST:event_itemCadastraDistribuidoresActionPerformed

    private void itemCadastraVendedoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemCadastraVendedoresActionPerformed
        new CadastroVendedores().setVisible(true);
    }//GEN-LAST:event_itemCadastraVendedoresActionPerformed

    private void itemCadastraProdutosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemCadastraProdutosActionPerformed
        new CadastroProdutos().setVisible(true);
    }//GEN-LAST:event_itemCadastraProdutosActionPerformed

    private void itemCadastraSaidaEstoqueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemCadastraSaidaEstoqueActionPerformed
        new CadastroSaidasEstoque().setVisible(true);
    }//GEN-LAST:event_itemCadastraSaidaEstoqueActionPerformed

    private void itemGerenciaCategoriasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemGerenciaCategoriasActionPerformed
        new GerenciaCategorias().setVisible(true);
    }//GEN-LAST:event_itemGerenciaCategoriasActionPerformed

    private void itemGerenciaDistribuidoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemGerenciaDistribuidoresActionPerformed
        new GerenciaDistribuidores().setVisible(true);

    }//GEN-LAST:event_itemGerenciaDistribuidoresActionPerformed

    private void itemGerenciaGarantiasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemGerenciaGarantiasActionPerformed
        new GerenciaGarantias().setVisible(true);

    }//GEN-LAST:event_itemGerenciaGarantiasActionPerformed

    private void itemGerenciaProdutosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemGerenciaProdutosActionPerformed
        new GerenciaProdutos().setVisible(true);
    }//GEN-LAST:event_itemGerenciaProdutosActionPerformed

    private void itemGerenciaVendedoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemGerenciaVendedoresActionPerformed
        new GerenciaVendedores().setVisible(true);
    }//GEN-LAST:event_itemGerenciaVendedoresActionPerformed

    private void itemSobreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemSobreActionPerformed
        JOptionPane.showMessageDialog(null, "Programa criado por Danilo Vicente Diorio \n\n\n Sob Licença GPL.");
    }//GEN-LAST:event_itemSobreActionPerformed

    private void btLimparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLimparActionPerformed
        limparTudo();
    }//GEN-LAST:event_btLimparActionPerformed

    private void corNome(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_corNome
        tfNome.setBackground(Color.white);
    }//GEN-LAST:event_corNome

    private void colorTelefone(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_colorTelefone
        tfTelefone.setBackground(Color.WHITE);
        
    
    }//GEN-LAST:event_colorTelefone

    private void corLista(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_corLista
        listaEmpresa.setBackground(Color.WHITE);
    }//GEN-LAST:event_corLista

    private void btVoltarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btVoltarActionPerformed
     int i = JOptionPane.showConfirmDialog(null, "Confirmação","Deseja realmente voltar?",JOptionPane.OK_OPTION);
     if(i == 0){
         new MenuPrincipal().setVisible(true);
         dispose();
     }
    }//GEN-LAST:event_btVoltarActionPerformed

    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CadastroVendedores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CadastroVendedores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CadastroVendedores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CadastroVendedores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new CadastroVendedores().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btCadastrar;
    private javax.swing.JButton btLimpar;
    private javax.swing.JButton btVoltar;
    private javax.swing.JMenuItem itemCadastraDistribuidores;
    private javax.swing.JMenuItem itemCadastraProdutos;
    private javax.swing.JMenuItem itemCadastraSaidaEstoque;
    private javax.swing.JMenuItem itemCadastraVendedores;
    private javax.swing.JMenuItem itemFechar;
    private javax.swing.JMenuItem itemGerenciaCategorias;
    private javax.swing.JMenuItem itemGerenciaDistribuidores;
    private javax.swing.JMenuItem itemGerenciaGarantias;
    private javax.swing.JMenuItem itemGerenciaProdutos;
    private javax.swing.JMenuItem itemGerenciaVendedores;
    private javax.swing.JMenuItem itemMenuCadastro;
    private javax.swing.JMenuItem itemMenuGerenciamento;
    private javax.swing.JMenuItem itemMenuPrincipal;
    private javax.swing.JMenuItem itemSobre;
    private javax.swing.JButton jButton4;
    private javax.swing.JList jList1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JLabel lbEmpresa;
    private javax.swing.JLabel lbNome;
    private javax.swing.JLabel lbTelefone;
    private javax.swing.JList listaEmpresa;
    private javax.swing.JMenu menuAjuda;
    private javax.swing.JMenu menuArquivo;
    private javax.swing.JMenu menuCadastro;
    private javax.swing.JMenu menuGerenciamento;
    private javax.swing.JPanel panelBoato;
    private javax.swing.JPanel panelDados;
    private javax.swing.JTextField tfNome;
    private javax.swing.JTextField tfTelefone;
    // End of variables declaration//GEN-END:variables

    private void limparTudo() {
        tfNome.setText(null);
        tfTelefone.setText(null);
        listaEmpresa.removeAll();
        listaEmpresa.setModel(modeloLista);
    }
    
    private void listarEmpresas(ArrayList<Distribuidor> listaEmpresas){
        if(listaEmpresas.isEmpty()){
            JOptionPane.showMessageDialog(null, "Nenhuma empresa Cadastrada");
        }else{
            for(int i =0;i<listaEmpresas.size();i++)
            modeloLista.addElement(listaEmpresas.get(i).getDistribuidor());
        }
    }
}
